package com.jinke.api.modules.ums.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinke.api.common.api.CommonPage;
import com.jinke.api.common.api.CommonResult;
import com.jinke.api.modules.app.request.UserRechargeRequest;
import com.jinke.api.modules.app.response.UserRechargeListVO;
import com.jinke.api.modules.app.service.UserRechargeService;
import com.jinke.api.modules.ums.request.ApproveRequest;
import com.jinke.api.modules.ums.request.RechargeRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@Api(value = "后台充值管理", tags = "后台充值管理")
@RequestMapping("/admin/recharge")
public class UmsRechargeController {

    @Resource
    UserRechargeService userRechargeService;

    @ApiOperation("审核")
    @PostMapping("/approve")
    @ResponseBody
    public CommonResult<?> approve(@RequestBody ApproveRequest request) {
        return CommonResult.success(userRechargeService.approve(request));
    }

    @ApiOperation("在线充值")
    @PostMapping("/recharge")
    @ResponseBody
    public CommonResult<?> recharge(@RequestBody RechargeRequest request) {
        return CommonResult.success(userRechargeService.recharge(request));
    }

    @ApiOperation("充值记录")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<UserRechargeListVO>> list(UserRechargeRequest request) {
        //CommonResult通用返回对象<CommonPage分页数据封装类<封装数据库类>>  List返回列表（请求类）

        // request.setUserId(AdminUserUtil.getUserId().intValue());
        Page<UserRechargeListVO> list = userRechargeService.list(request);
        //page分页<数据库类> list = 充值记录接口的list功能(返回请求)
        return CommonResult.success(CommonPage.restPage(list));
    }


}
